#include "header.h"
#include <iostream>
#include <iomanip>

using namespace std;
//===========P1=============
/*
class Scenario1 : public Scenario {
protected:
	void init();
	bool termCondition();
	void arrivalHandler(entity e);
	void serviceFinishHandler(Server server);
};
void Scenario1::init() {
	queueMgr.newQueue("FIFO",5);
	report = true;
	popMgr.file=true;
	serverMgr.newServer().serviceRate() = 3;
	arrivalRate = 3;
	queueMgr.report = true;
	serverMgr.report = true;
	popMgr.report = true;
}
bool Scenario1::termCondition() {
	return popMgr.getCount() >= 100;
}
void Scenario1::arrivalHandler(entity en) {
	Server server;
	server = serverMgr.getServer(0);
	if (server.isIdle() == true) {
		assign2Queue(en,0,clock);
		assign2Server(queueMgr.getQueue(0).dequeue(clock),0,clock);
	}
	else {
		assign2Queue(en,0,clock);
	}
}
void Scenario1::serviceFinishHandler(Server server) {
	Queue queue;
	server.deserver(clock);
	queue = queueMgr.getQueue(0);
	if (queue.getCount() >= 1) {
		assign2Server(queue.dequeue(clock),server.getId(),clock);
	}
}
*/
//===============P2==============
/*
class Scenario1: public Scenario {
protected:
	void init();
	bool termCondition();
	void arrivalHandler(entity e);
	void serviceFinishHandler(Server server);
	double arrivalDuration();
};

double serviceTime() {
	return 1;
}

double Scenario1::arrivalDuration() {
	return 2;
}

void Scenario1::init() {
	queueMgr.newQueue("FIFO", 2);
	report = true;
	file = false;
	serverMgr.newServer().serviceDurationFunc(&serviceTime);
}

bool Scenario1::termCondition() {
	return serverMgr.totalServed() >= 20;
}

void Scenario1::arrivalHandler(entity en) {
	Server server;
	server = serverMgr.getServer(0);
	assign2Queue(en,0,clock);
	if (server.isIdle() == true) {
		assign2Server(queueMgr.getQueue(0).dequeue(clock),0,clock);
	}
}
void Scenario1::serviceFinishHandler(Server server) {
	Queue queue;
	server.deserver(clock);
	queue = queueMgr.getQueue(0);
	if (queue.getCount() >= 1) {
		assign2Server(queue.dequeue(clock),server.getId(),clock);
	}
}
*/
int main() {
	try {
		cout << "==========mian() in test begin========" << endl;
//======random-source.cpp===========
/*
		PoissonProcess pp(3);
		unsigned i;
		for(i=100;i>0;i--) {
			cout << i << ',' << pp.event(i) << endl;
		}
		return 0;
*/
//=====entitie.cpp===========
/*
		PopulationMgr pop;
		entity a,b,c;
		unsigned i;
		pop.report=true;
		a=pop.newEntity();
		a.enqueue()=22;
		pop.newEntity();
		a=pop.newEntity();
		a.enqueue()=11;
		i=a.getId();
		a=pop.newEntity();
		b=pop.getEntity(i);
		c=b;
		b.enserver()=222;
		pop.getEntity(i).deserver()=3333;
		cout << c.enqueue() << endl;
		cout << c.enserver() << endl;
		cout << c.deserver() << endl;
		c=pop.newEntity();
		cout << pop.getEntity(i).enserver() <<endl;
*/
//=====   Inf Queue test   ===========
/*
		int i,t=0;
		PopulationMgr pop;
		QueueMgr qem;
		qem.report=true;
		Queue q;
		q=qem.newQueue("FIFO",0);
		for (i=0; i< 66; i++) {
			q.enqueue(pop.newEntity(),(double)t);
			t++;
		}
		for (i=0; i< 40; i++) {
			q.dequeue(t);
			t++;
		}
		for (i=0; i< 130; i++) {
			q.enqueue(pop.newEntity(),(double)t);
			t++;
		}
		qem.term(t);
*/
//=====queue.cpp&Server.cpp===========
/*
		PopulationMgr pop;
		QueueMgr qem;
		ServerMgr sem;
		Queue Q1,Q2;
		Server S1,S2;
		Q1=qem.newQueue("FIFO",5);
		Q2=qem.newQueue("LIFO",10);
		S1=sem.newServer();
		S2=sem.newServer();
		sem.report=true;
		pop.report=true;
		qem.report=true;
		Q1.enqueue(pop.newEntity(),1);
		Q2.enqueue(pop.newEntity(),1.5);
		Q1.enqueue(pop.newEntity(),3);
		Q2.enqueue(pop.newEntity(),10);
		S1.enserver(Q1,10.5);
		Q1.enqueue(pop.newEntity(),11);
		S1.deserver(11.5);
		S1.enserver(Q1,11.6);
		S1.deserver(11.7);
		S1.enserver(Q1,11.8);
		S2.enserver(Q2,11.9);
		S2.deserver(11.91);
		Q2.enqueue(pop.newEntity(),12);
		S2.enserver(Q2,13);
		S2.deserver(13.4);
		S2.enserver(Q2,13.5);
		S2.deserver(13.8);
		Q1.enqueue(pop.newEntity(),14.5);
		Q1.enqueue(pop.newEntity(),14.6);
		Q1.enqueue(pop.newEntity(),14.7);
		Q1.enqueue(pop.newEntity(),14.8);
		Q1.enqueue(pop.newEntity(),14.9);
		Q1.enqueue(pop.newEntity(),14.91);
		qem.term(16);
		sem.term(16);
*/
//=====    scenario.cpp    ===========

/*
		unsigned i=0,c[3];
		c[1]=c[2]=c[0]=0;
		setSeed(100);
		for (i = 0; i < 6000; i ++) {
			c[(unsigned)unifRand(0,3)]++;
		}
		for (i=0; i<3; i++) {
			cout << c[i] << endl;
		}
		cout << "==========mian() in test ended========" << endl;
*/
		long c=0;
		for (c = 0; c < 100000l; c++) {
			cout << BPRand(332, 10000000000.0, 1.1) << '\n';
		}
	}
	catch (char const * e) {
		cerr << ">>>>>>>>>> Error <<<<<<<<<<" << endl;
		cerr << e << endl;
		return 1;
	}
	return 1;
}

